"use strict";

module.exports = (app) => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const File = app.model.define("file", {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    origin_name: {
      type: STRING(64),
      allowNull: false,
      comment: "文件原始名称",
    },
    name: {
      type: STRING(64),
      allowNull: false,
      comment: "文件名称",
      unique: 'column',
    },
    path: {
      type: STRING(128),
      allowNull: false,
      comment: "文件路径",
      unique: 'column',
    },
    size: {
      type: INTEGER,
      allowNull: false,
      comment: "文件大小",
    },
    create_user_id: {
      type: INTEGER,
      allowNull: false,
      comment: "创建人"
    }
  });


  // set(val) {
  //   this.setDataValue("origin_name", encodeURI(val));
  // },
  // get() {
  //   const data=this.getDataValue("origin_name")
  //   return decodeURI(data);
  // },

  File.sync({ alter: true });

  return File;
};
